import java.io.*;

/**
 * Created by anatoliy
 * 16.08.13
 */
public class FileEncodingConverter {
    public static void main(String[] args) throws IOException {
        File files = new File("/home/anatoliy/Android Projects/SevaHymns/branches/DocAndFixedLoadiongException/assets/young");
        for (final File file : files.listFiles()) {
            final StringBuilder string = new StringBuilder();
            try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "cp1251"))) {
                while (bufferedReader.ready()) {
                    string.append(bufferedReader.readLine());
                    string.append('\n');
                }
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try (BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8"))) {
                        bufferedWriter.write(string.toString());
                    } catch (IOException e) {
                        System.err.println(e.getCause());
                    }
                }
            }).start();
        }
    }
}
